package com.klangner.move.behavior
{
  import com.klangner.geom.Vector2D;
  
  public class SeekBehavior implements IBehavior
  {
    private var _target:Vector2D;
    
    /**
    * Constructor
    * @param point seek from this point
    */
    public function SeekBehavior(point:Vector2D = null){
      if(null == point){
        _target = new Vector2D();
      }
      else{
        _target = point;
      }
    }
    
    public function set target(t:Vector2D):void{
      _target = t;
    }
    
    public function updateForce(obj:ISteeredObject):void{
      var velocity:Vector2D = Vector2D.subtract(_target, obj.position);
      velocity.normalize();
      obj.setDesiredVelocity(velocity);
    }

  }
}